<%@page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%@page import="org.jpass.dc.business.admin.bean.AdminBean"%>
<%@page import="java.text.SimpleDateFormat"%>
<%
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
	AdminBean admin = (AdminBean) request.getAttribute("admin");
	String birthdayStr ="";
	if(admin.getBirthday()!=null){
		birthdayStr = (String)sdf.format(admin.getBirthday());
	}
	String createdTimeStr ="";
	if(admin.getCreatedTime()!=null){
		createdTimeStr = (String)new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(admin.getCreatedTime());
	}
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>管理员信息表单</title>
<script type="text/javascript"
	src="/daycodefront/lib/extjs/adapter/ext/ext-base.js"></script>
<script type="text/javascript"
	src="/daycodefront/lib/extjs/ext-all-debug.js"></script>
<script type="text/javascript"
	src="/daycodefront/lib/extjs/src/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript"
	src="/daycodefront/common/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" src="msgBox.js"></script>
<script type="text/javascript">
	
	/**修改按钮**/
	function updateAdminInfo() {
		var form = document.forms['adminInfoForm'];
		var sexStr = document.getElementById("sexSelect").value;
		form.sex.value = sexStr;
		Ext.Ajax.request({
		    url : form.action,
		    method : 'POST',
		    params : {
		    	"adminBean.id" : form.id.value,
		    	"adminBean.realName" : form.realName.value,
		    	"adminBean.sex" : form.sex.value,
		    	"adminBean.birthday" : form.birthday.value,
		    	"adminBean.notes" : form.notes.value
		    },
		    success : function(response, options){
			    var res = Ext.util.JSON.decode(response.responseText);
			    if(res.success){// 判断请求是否成功
			    	window.parent.frames.welcome(res.level,res.realName);
			    	window.parent.frames.msgBox_close();
			    } else {
			    	alert(res.msg);
			    }
		    },
		    failure : function(response, options){
		    }
	    });
	}
</script>
<style type="text/css">
* { margin: 0px; padding: 0px; }
table { font: 14px 'Microsoft YaHei', '微软雅黑'; }
table tr { height: 40px; }
table tr td input { height: 23px; }
.title { text-align:right;  }
.headPhoto { position: absolute; right: 15px; top: 10px; width: 100px; height: 140px; }
.photo { height: 100px; border: thin solid #93FF93; }
.edit { height: 25px; margin-top: 2px; text-align: center; }
.birthday img:HOVER{ cursor:pointer;}
.notes{ width:600px;height:100px;overflow-x:visible;overflow-y:visible}
</style>
</head>
<body onload="initInfo();">
	<div class="content">
		<form action="updateAdminInfo" name="adminInfoForm">
			<input type="hidden" id="id" name="id" value="<%=admin.getId()%>" />
			<br />
			<br />
			<table width="100%" border="0">
				<tr>
					<td width="14%" class="title">用户名：</td>
					<td><span><%=admin.getName()%></span></td>
					<td width="23%" class="title">真实姓名：</td>
					<td><input type="text" name="realName" style="width: 200px;"
						value="<%=admin.getRealName()%>" />
					</td>
				</tr>
				<tr>
					<td class="title">性别：</td>
					<td><select id="sexSelect" style="width: 50px;">
							<option value=""></option>
							<option value="男">男</option>
							<option value="女">女</option>
					</select> <input type="hidden" id="sex" name="sex" value="" />
					</td>
					<td class="title">出生年月：</td>
					<td class="birthday"><input id="birthday" type="text"
						name="birthday" style="width: 180px;" onfocus="WdatePicker();"
						readonly="readonly" value="<%=birthdayStr%>" /> <img
						onclick="WdatePicker({el:'birthday'})"
						src="/daycodefront/common/My97DatePicker/skin/datePicker.gif"
						width="16" height="22" align="absmiddle" />
					</td>
				</tr>
				<tr>
					<td class="title">创建时间：</td>
					<td><span><%=createdTimeStr%></span>
					</td>
					<td class="title">登录次数：</td>
					<td><span><%=admin.getLoginTimes()%></span>
					</td>
				</tr>
				<tr>
					<td class="title" id="levelName">权限等级：</td>
					<td colspan="4"><select id="level" style="width: 200px;" >
							<option value="3">普通管理员</option>
							<option value="2">中级管理员</option>
							<option value="1">高级管理员</option>
					</select>
					</td>
				</tr>
				<tr>
					<td class="title">备注：</td>
					<td colspan="3"><textarea id="notes" type="text" class="notes"
							name="notes"></textarea>
					</td>
				</tr>
			</table>
		</form>
	</div>
</body>
<script type="text/javascript">
	function initInfo() {
		if('<%=admin.getAuthority()%>'=="0"){//只有管理员才能管理系统管理员
			document.getElementById("levelName").style.display="none";
			document.getElementById("level").style.display="none";
			}
		document.getElementById("sexSelect").value = '<%=admin.getSex()%>';
		document.getElementById("level").value = '<%=admin.getAuthority()%>';
		document.getElementById("notes").value = '<%=admin.getNotes()%>';
	}
	function back11() {
		<%-- if("success"==<%=resultStr%>){
			window.parent.contentWindow.msgBox_close();
		}else if("false"==<%=resultStr%>){
			alert(<%=tipStr%>);
			return false;
		} --%>
	}
</script>
</html>
